var vm = new Vue({
    el:'#details',
    data(){
        return{
            dto:{},
            fund:{},
            showFlag:false,
            showList:false,
            second:false,
            testID:"",
            title:"",
            dto1: {},
            tableData:[],//交易记录
            page1:1,
            pages1:"",
            limit1:10,
            loginTables:[],//登入记录
            userLogTables:[],
            page2:1,
            pages2:"",
            limit2:10,
            page3:1,
            pages3:"",
            limit3:10,

        }
    },
    mounted(){
        this.getFund();
        this.getData();
        this.getTable();
        this.getLogin();
        this.userLogDetail();
    },
    methods:{
        freeDetail(){
            this.getTable();
        },
        loginDetail(){
            this.getLogin();
        },
        userLogDetail(){
            var that = this;
            $.ajax({
                type: "GET",
                url: baseURL + 'user/userLogList?page='+that.page3+'&limit='+that.limit3+'&p='+T.p("id"),
                dataType: "json",
                contentType: "application/json",
                cache : false,
                async : false,
                success: function(res){
                    console.log(res)
                    if(res.code==0 &&  res.page.list){
                        that.userLogTables=res.page.list;
                        that.pages3=res.page.total
                        console.log(that.pages3);
                        // that.pages2Count()
                    }
                },
                err:function (err) {
                    console.log(err)
                }
            })
        },
        //获取用户资金信息
        getFund(){
            var that = this;
            $.ajax({
                type: "GET",
                url: baseURL+'fund/info/userid/' +T.p("id"),
                dataType: "json",
                contentType: "application/json",
                cache : false,
                async : false,
                success: function(res){
                    console.log(res)
                    if(res.code==0){
                        that.fund=res.dto;
                        console.log(that.dto)
                    }
                },
                err:function (err) {
                    console.log(err)
                }
            })
        },
        //获取用户基本信息
        getData(){
            var that = this;
            $.ajax({
                type: "GET",
                url: baseURL+'user/info/' +T.p("id"),
                dataType: "json",
                contentType: "application/json",
                cache : false,
                async : false,
                success: function(res){
                    if(res.code==0){
                       that.dto=res.dto;
                       console.log(that.dto)
                    }
                },
                err:function (err) {
                    console.log(err)
                }
            })
        },
        //获取转账详情信息
        reload: function (event) {
            // console.log(T.p("phone"));
            // var phoneNumg=T.p("phone")
            // var _postData = $("#jqGrid").jqGrid('getGridParam','postData');
            // // _postData['p'] = phoneNumg;
            // var page = $("#jqGrid").jqGrid('getGridParam','page');
            // $("#jqGrid").jqGrid('setGridParam',{
            //     page:page
            // }).trigger("reloadGrid");
        },
        //获取转账详情信息
        getTable(){
            var that = this;
            $.ajax({
                type: "GET",
                url: baseURL + 'tradeinfo/list/?p='+T.p("phone")+'&page='+that.page1+'&limit='+that.limit1,
                dataType: "json",
                contentType: "application/json",
                cache : false,
                async : false,
                success: function(res){
                    console.log(res)
                    if(res.code==0){
                        if(res.page){
                        that.tableData=res.page.list;
                        console.log(that.tableData);
                        that.pages1=res.page.total;
                        console.log(that.pages1);
                        }
                    }
                },
                err:function (err) {
                    console.log(err)
                }
            })

        },
        //获取登入记录
        getLogin(){
            var that = this;
            $.ajax({
                type: "GET",
                url: baseURL + 'base/userlogin/list?page='+that.page2+'&limit='+that.limit2+'&userId='+T.p("id"),
                dataType: "json",
                contentType: "application/json",
                cache : false,
                async : false,
                success: function(res){
                    console.log(res)
                    if(res.code==0 &&  res.page.list){
                        that.loginTables=res.page.list;
                        that.pages2=res.page.total
                        console.log(that.pages2);
                        // that.pages2Count()
                    }
                },
                err:function (err) {
                    console.log(err)
                }
            })

        },
        //操作修改
        showDiago(text,money,localmoney){
            this.title= text;
                this.dto1 = {'phone':vm.dto.phone,};
                // this.second=true;

            layer.open({
                type: 1,
                skin: 'layui-layer-rim',
                title: text,
                area: ['625px', '386px'],
                shadeClose: true,
                anim: 1, //动画类型
                shade: 0.01 ,//遮罩透明度
                content: jQuery("#chargeLayer"),
                btn: ['确定','取消'],
                btn1: function (index)
                {
                    // var data = {userId:id, phone:phone, money:this.dto.money,};
                    if(text=="流通IMU"){
                        var data = {'money':vm.dto1.money,'ytfType':0, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="锁仓IMU"){
                        var data = {'money':vm.dto1.money,'ytfType':12, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="流通GET"){
                        var data = {'money':vm.dto1.money,'ytfType':15, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="锁仓GET"){
                        var data = {'money':vm.dto1.money,'ytfType':4, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="流通KCT"){
                        var data = {'money':vm.dto1.money,'ytfType':3, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="锁仓KCT"){
                        var data = {'money':vm.dto1.money,'ytfType':14, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="交易易买宝"){
                        var data = {'money':vm.dto1.money,'ytfType':2, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="锁仓易买宝"){
                        var data = {'money':vm.dto1.money,'ytfType':11, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="合赢分"){
                        var data = {'money':vm.dto1.money,'ytfType':10, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="交易贝壳"){
                        var data = {'money':vm.dto1.money,'ytfType':16, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    } else if(text=="锁仓贝壳"){
                        var data = {'money':vm.dto1.money,'ytfType':5, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }else if(text=="俱乐部等级"){
                        var data = {'money':vm.dto1.money,'ytfType':6, 'userId':vm.fund.userId,'remark':vm.dto1.description};
                        console.log(data)
                    }
                    confirm('确定要修改用户' + vm.dto.phone + '的'+text +"数量", function(){
                        console.log(data)
                        $.ajax({
                            type: "post",
                            async:false,
                            url: baseURL + "fund/updateMoney",
                            contentType: "application/json",
                            data: JSON.stringify(data),
                            success: function(r){
                                if(r.code == 0){
                                    layer.close(index);
                                    alert('操作成功', function(index){
                                        vm.getFund();
                                        // vm.getData();
                                    });
                                }else{
                                    alert(r.msg);
                                }
                            }
                        });
                    });
                }
            });
        },
        showDiago1(text){
            var txt,conunt;
            txt=text
            if(text=="交易员"){
                conunt="请问您确定是否取消交易员？"
            }else{
                conunt='请问您确定释放俱乐部等级吗？'
            }
            layer.open({
                title: text,
                content: conunt,
                yes: function(index, layero){
                    //do something
                    console.log(79879);
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    if(text=="交易员"){
                        var data = {'ytfType':1, 'userId':vm.fund.userId};
                        console.log(data)
                    }else{
                        var data = {'ytfType':0, 'userId':vm.fund.userId};
                        console.log(data)
                    }
                    $.ajax({
                        type: "post",
                        async:false,
                        url: baseURL + "fund/release",
                        contentType: "application/json",
                        data: JSON.stringify(data),
                        success: function(r){
                            if(r.code == 0){
                                layer.close(index);
                                alert('操作成功', function(index){
                                    vm.getFund();
                                });
                            }else{
                                alert(r.msg);
                            }
                        }
                    });
                }
            });
        },
        //返回
        goBackTo(){
            window.history.go(-1);
        },
    },

})

layui.use(['laypage', 'layer'], function(){
    var laypage = layui.laypage
        ,layer = layui.layer;
    laypage.render({
        elem: 'demo8'
        ,count: Number(vm.pages1)
        ,theme: '#1E9FFF'
        ,layout: ['limit','prev','page', 'next']
        ,jump: function(obj, first){
            console.log(obj)
            vm.page1=obj.curr;
            vm.limit1=obj.limit;
            if(!first){
                vm.getTable()
            }
        }
    });
});

layui.use(['laypage', 'layer'], function(){
    var laypage = layui.laypage
        ,layer = layui.layer;
    laypage.render({
        elem: 'demo9'
        ,count: Number(vm.pages2)
        ,theme: '#1E9FFF'
        ,layout: ['limit','prev','page', 'next']
        ,jump: function(obj, first){
            console.log(obj)
            vm.page2=obj.curr;
            vm.limit2=obj.limit;
            if(!first){
                vm.getLogin()
            }
        }
    });
});
layui.use(['laypage', 'layer'], function(){
    var laypage = layui.laypage
        ,layer = layui.layer;
    laypage.render({
        elem: 'demo10'
        ,count: Number(vm.pages3)
        ,theme: '#1E9FFF'
        ,layout: ['limit','prev','page', 'next']
        ,jump: function(obj, first){
            console.log(obj)
            vm.page3=obj.curr;
            vm.limit3=obj.limit;
            if(!first){
                vm.userLogDetail()
            }
        }
    });
});




